package com.zhiliao.prototype.demo2;

/**
 * @author zouxf Department:3cs
 * @copyright Copyright 2021-2021 JD.COM All Right Reserved
 * @create Date 2021/6/30 8:01
 * @description
 * @lastModifiedBy
 * @lastModifiedDate(yyyy/MM/dd)
 * @see
 */
public class PrototypeDemo2 {
    public static void main(String[] args) throws CloneNotSupportedException {
        Animal a1 = new Animal();
        a1.setName("snoopy");
        System.out.println(a1+"\t"+a1.getName());
        Animal a2 = a1.clone();
        System.out.println(a2+"\t"+a2.getName());
    }
}

interface CloneAdapter<T> extends Cloneable {
    T clone();
}

class Animal implements Cloneable{
    private String name;

    @Override
    public Animal clone() throws CloneNotSupportedException {
        return (Animal)super.clone();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
